package com.qing.design.patterns.builder.example.cars;

import com.qing.design.patterns.builder.example.components.Engine;
import com.qing.design.patterns.builder.example.components.GPSNavigator;
import com.qing.design.patterns.builder.example.components.Transmission;
import com.qing.design.patterns.builder.example.components.TripComputer;

/**
 * 汽车手册是另一种产品。请注意，它没有相同的祖先
 * 作为一辆汽车。他们没有关系。
 */
public class Manual {

	//汽车类型
	private   CarType carType;
	//座位
	private   int seats;
	//发动机
	private  Engine engine;
	//变速箱
	private  Transmission transmission;
	//车载电脑
	private  TripComputer tripComputer;
	//GPS 导航
	private  GPSNavigator gpsNavigator;

	public Manual(CarType carType, int seats, Engine engine, Transmission transmission, TripComputer tripComputer, GPSNavigator gpsNavigator) {
		this.carType = carType;
		this.seats = seats;
		this.engine = engine;
		this.transmission = transmission;
		this.tripComputer = tripComputer;
		this.gpsNavigator = gpsNavigator;
	}


	public String print() {
		String computerFlag="不存在！";
		String gpsFlag="不存在！";

		if(tripComputer!=null){
			computerFlag="存在！";
			gpsFlag="存在！";
		}
		if(gpsNavigator!=null){
			computerFlag="存在！";
			gpsFlag="存在！";
		}


		return "Manual{" +
				"汽车类型=" + carType +
				", 汽车座位=" + seats +
				", 发动机状态=" + engine.isStarted() +
				", 发动机里程=" + engine.getMileage() +
				", 发动机体积=" + engine.getVolume() +
				", 变速箱=" + transmission+
				", 车载电脑=" + computerFlag +
				", GPS 导航=" + gpsFlag +
				'}';
	}


}
